<?php
namespace app\backend\model;

use think\Config;
use think\Db;
use think\Loader;
use think\Model;
use traits\model\SoftDelete;
use app\backend\org\Recursion;

class  Lists extends Model
{
    //新闻模块
    protected $table = 'ls_list';
    public function getAll($type,$tab_id="")//$id为字符串
    {
        //var_dump($p_id);exit;
        $type_id = Type::where("remark_en",$type)->value("type_id");

        $data=$this
            ->field('list_id,p_id,list_title_cn,list_title_en,img_url,title_introduce_cn,title_introduce_en,is_recommend,type_id,is_enable')
            ->where("type_id",$type_id);
          //  ->where("p_id",$tab_id);
//            ->where("p_id","exp", 'in ($id)')
        //
        /*if($id != ""){
          $data =  $data ->where(["p_id" => ["exp", "in ($id)"]]);
        }*/
        if($tab_id != ""){
            $data =  $data ->where(["p_id" => $tab_id]);
        }

          $data->order("is_recommend DESC");
        //->select();
        return $data;
    }

    use SoftDelete;
    static protected $deleteTime = 'delete_time';


    public function getnav($org){
        // var_dump($org);exit;
        // 查询数据
        //implode(",",$org).')将数组个元素连接成字符串，元素之间用“，”
        $data =$this
            ->field('stage_id,p_id,stage_title_cn,stage_title_en,img_url,content_cn,content_en,pdf,is_recommend')
            ->where(array("p_id"=>array("exp",'in('.implode(",",$org).')')))
            ->order("is_recommend DESC");

//self对类自己本身的引用
        //$arr=Recursion::_child_id($data); //得到菜单数组
        //echo "<pre>";
        //print_r($arr);exit;
        //$json=json_encode($arr);
        return $data; //返回json格式
    }

}